package com.zhou.rpc;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Tut6Config
 *
 * @author zhouxianfeng
 * @date 2021-5-24
 */
@Configuration
public class Tut6Config {

    @Bean
    public DirectExchange exchange() {
        return new DirectExchange("tut.rpc");
    }

    @Bean
    public Queue rpcQueue() {
        return new Queue("tut.rpc.requests");
    }

    @Bean
    public DirectExchange directExchange() {
        return new DirectExchange("tut.rpc");
    }

    @Bean
    public Binding binding(DirectExchange directExchange,
                           Queue rpcQueue) {
        return BindingBuilder.bind(rpcQueue)
                .to(directExchange)
                .with("rpc");
    }
}
